/**
  其他境外交流项目审核列表页
*/
<template>
    <div class="exchange-project-audit-container">
        <div v-if="indexKey === 1">
            <condition-card
                @reset="reset"
                @search="onSubmit"
                label-position="right"
                label-width="150px"
            >
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="8">
                        <!-- 项目子类别 -->
                        <el-form-item
                            :label="$t('projectManage.projectSubCategory')"
                            prop="projectSubCategory"
                        >
                            <el-select
                                v-model="queryForm.condition.projectSubCategory"
                                :placeholder="$t('common.pla.pleaseSelect')"
                                clearable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.projectSubCategory"
                                    :key="item.id"
                                    :label="item.typeName"
                                    :value="item.id"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <!-- 学院 -->
                        <el-form-item
                            v-if="permitToManageCollege"
                            :label="$t('externamExchangeBase.college')"
                            prop="studentFaculty"
                        >
                            <el-select
                                disabled
                                v-model="queryForm.condition.studentFaculty"
                                filterable
                                @change="changeCollege"
                                :placeholder="$t('common.pla.pleaseSelect')"
                                clearable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.studentFaculty"
                                    :key="item.key"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item
                            v-else
                            :label="$t('externamExchangeBase.college')"
                            prop="studentFaculty"
                        >
                            <el-select
                                v-model="queryForm.condition.studentFaculty"
                                filterable
                                @change="changeCollege"
                                :placeholder="$t('common.pla.pleaseSelect')"
                                clearable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.studentFaculty"
                                    :key="item.key"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <!-- 专业 -->
                        <el-form-item
                            :label="$t('externamExchangeBase.profession')"
                            prop="studentProfession"
                        >
                            <el-select
                                v-model="queryForm.condition.studentProfession"
                                filterable
                                :placeholder="$t('common.pla.pleaseSelect')"
                                clearable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.studentProfession"
                                    :key="item.key"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24" style="height: 50px;margin-left: -13px;">
                    <el-col :span="8">
                        <!-- 国家地区 -->
                        <el-form-item
                            :label="$t('exchangeProjectAudit.projectNationCode')"
                            prop="projectNationCode"
                        >
                            <el-select
                                v-model="queryForm.condition.projectNationCode"
                                @change="changeNation"
                                filterable
                                :placeholder="$t('common.pla.pleaseSelect')"
                                clearable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.projectNationCode"
                                    :key="item.key"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <!-- 合作大学 -->
                        <el-form-item
                            :label="$t('externamExchangeBase.cooperativeUniversity')"
                            prop="projectCollegeId"
                        >
                            <el-select
                                v-model="queryForm.condition.projectCollegeId"
                                :placeholder="$t('common.pla.pleaseSelect')"
                                clearable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.projectCollegeId"
                                    :key="item.id"
                                    :label="item.collegeName"
                                    :value="item.id"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <!-- 项目开始时间 -->
                        <el-form-item
                            :label="$t('projectApplication.projectStartTime')"
                            prop="projectStartTimeStr"
                        >
                            <el-date-picker
                                style="width: 100%"
                                v-model="queryForm.condition.projectStartTimeStr"
                                type="date"
                                value-format="yyyy-MM-dd"
                                :placeholder="$t('graduateBase.chooseDateAndTime')"
                                :picker-options="xmkssjPickerOptions"
                            ></el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="8">
                        <!-- 项目结束时间 -->
                        <el-form-item
                            :label="$t('projectApplication.projectEndTime')"
                            prop="projectEndTimeStr"
                        >
                            <el-date-picker
                                style="width: 100%"
                                v-model="queryForm.condition.projectEndTimeStr"
                                type="date"
                                value-format="yyyy-MM-dd"
                                :placeholder="$t('graduateBase.chooseDateAndTime')"
                                :picker-options="xmjssjPickerOptions"
                            ></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <!-- 学号/姓名 -->
                        <el-form-item
                            :label="$t('exchangeProjectAudit.studentParam')"
                            prop="studentParam"
                        >
                            <el-input
                                :placeholder="$t('common.pla.pleaseInput')"
                                v-model="queryForm.condition.studentParam"
                                clearable
                                :maxlength="32"
                                style="width: 100%"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <!-- 出国审核状态 -->
                        <el-form-item
                            :label="$t('exchangeProjectAudit.goAbroadAuditStatus')"
                            prop="applyStatus"
                        >
                            <el-select
                                v-model="queryForm.condition.applyStatus"
                                :placeholder="$t('common.pla.pleaseSelect')"
                                clearable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.applyStatus"
                                    :key="item.key"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <!-- 报销审核状态，专家角色不展示 -->
                <el-row :gutter="24" style="height: 50px;" v-if="!permitToBatchAudit">
                    <el-col :span="8">
                        <!-- 报销审核状态 -->
                        <el-form-item
                            :label="$t('exchangeProjectAudit.goHomeReimbursementStatus')"
                            prop="backApplyStatus"
                        >
                            <el-select
                                v-model="queryForm.condition.backApplyStatus"
                                :placeholder="$t('common.pla.pleaseSelect')"
                                clearable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.backApplyStatus"
                                    :key="item.key"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </condition-card>
            <el-card
                shadow="never"
                v-loading="loading"
                body-style="padding: 24px;"
                class="card-margin"
            >
                <h1 class="condition-title">{{$t('exchangeProjectAudit.auditTitle')}}</h1>
                <div class="edu-opertion-bar sub-title">
                    <div class="float-right" style="display: flex;">
                        <el-dropdown
                            v-if="permitToBatchDownloadFiles"
                            @command="downloadFileBatchly"
                        >
                            <el-button type="primary">
                                {{ $t('exchangeProjectAudit.batchDownloadFile') }}
                                <i
                                    class="el-icon-arrow-down el-icon--right"
                                ></i>
                            </el-button>
                            <el-dropdown-menu slot="dropdown">
                                <!-- 出国 -->
                                <el-dropdown-item
                                    command="1"
                                >{{ $t('exchangeProjectAudit.goAbroadApply') }}</el-dropdown-item>
                                <!-- 回国 -->
                                <el-dropdown-item
                                    v-if="permitToDownExperts || permitToManageCollege"
                                    command="2"
                                >{{ $t('exchangeProjectAudit.returnHomeBaoXiao') }}</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>

                        <!-- 非管理员的通过 -->
                        <el-button
                            v-if="permitToBatchPass"
                            type="primary"
                            @click="passBatchly()"
                        >{{ $t('externamExchangeBase.pass') }}</el-button>
                        <!-- 管理员的通过 -->
                        <el-button
                            v-if="permitToBatchPassManage"
                            type="primary"
                            @click="managerPassBatchly()"
                        >{{ $t('externamExchangeBase.pass') }}</el-button>
                        <el-button
                            v-if="permitToBatchNoPass"
                            @click="notPassBatchly()"
                        >{{ $t('externamExchangeBase.notPass') }}</el-button>
                        <el-button
                            v-if="permitToBatchTurnDown"
                            @click="turnDownBatchly()"
                        >{{ $t('externamExchangeBase.reject') }}</el-button>
                        <!-- 专家批量评审 -->
                        <el-button
                            v-if="permitToBatchAudit"
                            type="primary"
                            @click="batchAudit()"
                        >{{ $t('exchangeProjectAudit.batchAudit') }}</el-button>
                        <el-button
                            v-if="permitToBatchExport"
                            @click="exportBatchly()"
                        >{{ $t('externamExchangeBase.export') }}</el-button>
                    </div>
                </div>
                <edu-table
                    :pagination="false"
                    :order="true"
                    :tooltipEffect="tooltipEffect"
                    stripe
                    :data="dataList"
                    size="mini"
                    @selection-change="handleSelectionChange"
                >
                    <edu-table-column
                        :label="$t('externamExchangeBase.studentId')"
                        prop="studentId"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('externamExchangeBase.studentName')"
                        prop="studentName"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('externamExchangeBase.college')"
                        prop="studentFacultyName"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('externamExchangeBase.profession')"
                        prop="studentProfessionName"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('projectManage.projectSubCategory')"
                        prop="projectSubCategoryName"
                        width="100"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('projectManage.projectName')"
                        prop="projectMngmtName"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('interdisciplinaryManagement.country')"
                        prop="projectNationName"
                    >
                        <template slot-scope="scope">
                            <div v-if="scope.row.changes.length > 0">
                                <span
                                    v-if="scope.row.changes[0].nationChanged"
                                    style="color: red;"
                                >{{ scope.row.changes[0].countryRegion }}</span>
                                <span v-else>{{ scope.row.projectNationName }}</span>
                            </div>
                            <div v-else>{{ scope.row.projectNationName }}</div>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('externamExchangeBase.cooperativeUniversity')"
                        prop="projectCollegeCn"
                    >
                        <template slot-scope="scope">
                            <div v-if="scope.row.changes.length > 0">
                                <span
                                    v-if="scope.row.changes[0].collegeChanged"
                                    style="color: red;"
                                >{{ scope.row.changes[0].cooperateUniversity }}</span>
                                <span v-else>{{ scope.row.projectCollegeCn }}</span>
                            </div>
                            <div v-else>{{ scope.row.projectCollegeCn }}</div>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('projectApplication.projectStartTime')"
                        prop="projectStartTime"
                        width="110"
                    >
                        <template slot-scope="scope">
                            <div v-if="scope.row.changes.length > 0">
                                <span
                                    v-if="scope.row.changes[0].startTimeChanged"
                                    style="color: red;"
                                >{{ scope.row.changes[0].projectStartTime }}</span>
                                <span v-else>{{ scope.row.projectStartTime }}</span>
                            </div>
                            <div v-else>{{ scope.row.projectStartTime }}</div>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('projectApplication.projectEndTime')"
                        prop="projectEndTime"
                        width="110"
                    >
                        <template slot-scope="scope">
                            <div v-if="scope.row.changes.length > 0">
                                <span
                                    v-if="scope.row.changes[0].endTimeChanged"
                                    style="color: red;"
                                >{{ scope.row.changes[0].projectEndTime }}</span>
                                <span v-else>{{ scope.row.projectEndTime }}</span>
                            </div>
                            <div v-else>{{ scope.row.projectEndTime }}</div>
                        </template>
                    </edu-table-column>
                    <!-- 实际出国时间，专家角色不展示 -->
                    <edu-table-column
                        v-if="!permitToBatchAudit"
                        :label="$t('projectApplication.realStartTime')"
                        prop="realStartTime"
                        width="110"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.back">{{ scope.row.back.realStartTime }}</span>
                        </template>
                    </edu-table-column>
                    <!-- 实际回国时间，专家角色不展示 -->
                    <edu-table-column
                        v-if="!permitToBatchAudit"
                        :label="$t('projectApplication.realEndTime')"
                        prop="realEndTime"
                        width="110"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.back">{{ scope.row.back.realEndTime }}</span>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('projectApplication.projectStudyAbroadContent')"
                        prop="projectStudyAbroadContent"
                    ></edu-table-column>
                    <!-- 学校管理员-专家 -->
                    <edu-table-column
                        v-if="permitToSpecifyExperts"
                        :label="$t('exchangeProjectAudit.experts')"
                        prop="applyExpertTeacherName"
                    >
                        <template slot-scope="scope">
                            <span
                                v-if="scope.row.applyExpertTeacherName"
                            >{{ scope.row.applyExpertTeacherName }}</span>
                        </template>
                    </edu-table-column>
                    <!-- 出国申请审核状态 -->
                    <edu-table-column
                        :label="$t('projectApplication.goAbroadAuditStatus')"
                        prop="applyStatus"
                        width="135"
                    >
                        <template slot-scope="scope">
                            <el-tag
                                :type="scope.row.applyStatus | getApplyStatusType"
                            >{{ scope.row.applyStatus | goAbroadAuditStatus }}</el-tag>
                        </template>
                    </edu-table-column>
                    <!-- 是否录取 -->
                    <edu-table-column
                        :label="$t('projectApplication.participantPass')"
                        prop="participantPass"
                    >
                        <template slot-scope="scope">
                            <el-tag
                                v-if="scope.row.projectSubCategory === 6 && (scope.row.participantPass === 1 || scope.row.participantPass === 2 || scope.row.participantPass === 3)"
                                :type="scope.row.participantPass | getAdmissionType"
                            >{{ scope.row.participantPass | participantPass }}</el-tag>
                        </template>
                    </edu-table-column>
                    <!-- 下一级审批人 -->
                    <!-- <edu-table-column :label="$t('externamExchangeBase.nextAuditPerson')" width="110">
             <template slot-scope="scope">
               <span v-if="permitToBatchNoNextAudit">{{scope.row.approverNameCopy}}</span>
               <span v-if="permitToBatchNextAudit">{{scope.row.approverName}}</span>
            </template>
                    </edu-table-column>-->
                    <edu-table-column
                        :label="$t('externamExchangeBase.nextAuditPerson')"
                        prop="approverNameCopy"
                        width="110"
                    ></edu-table-column>
                    <!-- 操作 -->
                    <edu-table-column
                        :label="$t('common.text.operation')"
                        prop="operation"
                        fit
                        width="130"
                    >
                        <template slot-scope="scope">
                            <el-button
                                v-if="permitToSelectGoAbroad"
                                type="text"
                                @click="selectGoAbroad(scope.row)"
                            >{{$t('message.Look')}}</el-button>
                            <!-- 只有导师/专家数据为已提交状态才可审核，其他角色均为审核中才可审核 -->
                            <el-button
                                v-if="permitToAuditGoAbroad && scope.row.canAudit"
                                type="text"
                                @click="auditGoAbroad(scope.row)"
                            >{{$t('externamExchangeBase.audit')}}</el-button>
                            <!-- 下载资助函最后管理员审核通过后可操作 -->
                            <el-button
                                v-if="permitToDownloadFunding && scope.row.applyStatus === 4 && scope.row.projectSubCategory === 7"
                                type="text"
                                @click="downloadFunding(scope.row)"
                            >{{$t('exchangeProjectAudit.downloadGrantLetter')}}</el-button>
                        </template>
                    </edu-table-column>
                    <!-- 报销状态 -->
                    <edu-table-column
                        v-if="permitToBXStatus"
                        :label="$t('exchangeProjectAudit.reimbursementStatus')"
                        prop="returnHomeReimbursement"
                        width="80"
                    >
                        <template slot-scope="scope">
                            <el-tag
                                v-if="scope.row.back"
                                :type="scope.row.back.applyStatus | getApplyStatusType"
                            >{{ scope.row.back.applyStatus | returnHomeReimbursement }}</el-tag>
                        </template>
                    </edu-table-column>
                    <!-- 报销下一级审批人，专家角色不展示 -->
                    <edu-table-column
                        v-if="!permitToBatchAudit"
                        :label="$t('externamExchangeBase.baoxiaoNextAuditPerson')"
                        prop="approverName"
                        width="135"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.back">{{ scope.row.back.approverName }}</span>
                        </template>
                    </edu-table-column>
                    <!-- 报销操作 -->
                    <edu-table-column
                        v-if="permitToBXOperate"
                        :label="$t('projectApplication.baoxiaoAndBaoDaoOperate')"
                        fit
                        width="200"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.back && scope.row.projectSubCategory === 6">
                                <!-- 查看 -->
                                <el-button
                                    v-if="permitToSelectReturnHomeBX"
                                    type="text"
                                    @click="selectReturnHomeBX(scope.row)"
                                >{{$t('message.Look')}}</el-button>
                            </span>
                            <!-- 审核和查看回国 -->
                            <span v-if="scope.row.back && scope.row.projectSubCategory === 7">
                                <!-- 查看 -->
                                <el-button
                                    v-if="permitToSelectReturnHomeBX"
                                    type="text"
                                    @click="selectReturnHomeBX(scope.row)"
                                >{{$t('message.Look')}}</el-button>
                                <!-- 审核 -->
                                <el-button
                                    v-if="permitToAuditReturnHomeBX && scope.row.back.canAudit"
                                    type="text"
                                    @click="auditReturnHomeBX(scope.row)"
                                >{{$t('externamExchangeBase.audit')}}</el-button>
                            </span>
                        </template>
                    </edu-table-column>
                </edu-table>
                <el-row type="flex" class="row-bg" justify="end">
                    <el-col>
                        <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="queryForm.pageNum_"
                            :page-sizes="[20, 40, 80, 100]"
                            :page-size="queryForm.pageSize_"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="queryForm.total_"
                            style="float:right;margin-top:10px"
                        ></el-pagination>
                    </el-col>
                </el-row>
            </el-card>
        </div>
        <!-- 查看出国开始 -->
        <div v-if="indexKey === 2">
            <audit-go-abroad-for-select
                :applyId="applyId"
                :applyActExpert="applyActExpert"
                :subsidizeFillIn="subsidizeFillIn"
                :projectSubCategory="projectSubCategory"
                @change-project-index="changeProjectIndex"
            ></audit-go-abroad-for-select>
        </div>
        <!-- 查看出国结束 -->
        <!-- 审核出国开始 -->
        <div v-if="indexKey === 3">
            <audit-go-abroad
                :applyId="applyId"
                :applyActExpert="applyActExpert"
                :projectSubCategory="projectSubCategory"
                :subsidizeFillIn="subsidizeFillIn"
                @change-project-index="changeProjectIndex"
            ></audit-go-abroad>
        </div>
        <!-- 审核出国结束 -->
        <!-- 查看回国开始 -->
        <div v-if="indexKey === 4">
            <select-return-home
                :showProcess="showProcess"
                :applyId="applyId"
                :backId="backId"
                :projectSubCategory="projectSubCategory"
                :projectStartTime="projectStartTime"
                :projectEndTime="projectEndTime"
                @change-project-index="changeProjectIndex"
            ></select-return-home>
        </div>
        <!-- 查看回国结束 -->

        <!-- 查看回国开始 -->
        <div v-if="indexKey === 6">
            <return-home-select
                :showProcess="showProcess"
                :tabTitle="tabTitle"
                :applyId="applyId"
                :backId="backId"
                :projectSubCategory="projectSubCategory"
                :projectStartTime="projectStartTime"
                :projectEndTime="projectEndTime"
                @change-project-index="changeProjectIndex"
            ></return-home-select>
        </div>
        <!-- 查看回国结束 -->

        <!-- 审核回国开始 -->
        <div v-if="indexKey === 5">
            <audit-return-home
                :applyId="applyId"
                :backId="backId"
                :projectStartTime="projectStartTime"
                :projectEndTime="projectEndTime"
                @change-project-index="changeProjectIndex"
            ></audit-return-home>
        </div>
        <!-- 审核回国结束 -->
        <!-- 输入审核意见弹框开始 -->
        <el-dialog
            :title="title"
            width="30%"
            ref="dialogForm"
            :before-close="beforeClose"
            :visible.sync="dialogVisible"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form :model="dialogForm" label-position="right" ref="dialogForm" label-width="80px">
                <el-row>
                    <el-col :span="24">
                        <el-form-item
                            :label="$t('exchangeProjectAudit.auditOpinion') + '：'"
                            prop="content"
                            :rules="[{ validator: checkSpecial, trigger: 'blur'}]"
                        >
                            <el-input
                                type="textarea"
                                :rows="5"
                                :maxlength="500"
                                :placeholder="$t('common.pla.pleaseInput')"
                                v-model="dialogForm.content"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <template>
                    <el-button @click="beforeClose()">{{ $t('common.btn.cancel') }}</el-button>
                    <el-button
                        type="primary"
                        @click="confirm('dialogForm')"
                    >{{ $t('common.btn.confirm') }}</el-button>
                </template>
            </span>
        </el-dialog>
        <!-- 输入审核意见弹框结束 -->
        <!-- 输入资助信息弹框开始 -->
        <el-dialog
            :title="title"
            width="30%"
            ref="fundingFormDialog"
            :before-close="cancelFundingDialog"
            :visible.sync="fundingDialogVisible"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form
                :model="fundingForm"
                label-position="right"
                ref="fundingForm"
                label-width="140px"
            >
                <el-row>
                    <el-col :span="24">
                        <!-- 资助期限 -->
                        <el-form-item
                            :label="$t('projectApplication.projectFundingPeriod') + '：'"
                            prop="projectFundingPeriod"
                            :rules="[{ required: true, message: $t('projectApplication.requireProjectFundingPeriod'), trigger: 'blur'},{ validator: checkSpecial, trigger: 'blur' },{ validator: checkPositiveInteger, trigger: 'blur'}]"
                        >
                            <el-input
                                v-model="fundingForm.projectFundingPeriod"
                                :maxlength="9"
                                clearable
                                :placeholder="$t('common.pla.pleaseInput')"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <!-- 资助标准 -->
                        <el-form-item
                            :label="$t('exchangeProjectAudit.subsidizeStandard') + '：'"
                            prop="subsidizeStandard"
                            :rules="[{ required: true, message: $t('exchangeProjectAudit.requireSubsidizeStandard'), trigger: 'blur'},{ validator: checkSpecial, trigger: 'blur' }]"
                        >
                            <el-input
                                v-model="fundingForm.subsidizeStandard"
                                :maxlength="32"
                                clearable
                                :placeholder="$t('common.pla.pleaseInput')"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <!-- 资助金额 -->
                        <el-form-item
                            :label="$t('exchangeProjectAudit.subsidizeAmount') + '：'"
                            prop="subsidizeAmount"
                            :rules="[{ required: true, message: $t('exchangeProjectAudit.requireSubsidizeAmount'), trigger: 'blur'},{ validator: checkSpecial, trigger: 'blur' }]"
                        >
                            <el-input
                                v-model="fundingForm.subsidizeAmount"
                                :maxlength="32"
                                clearable
                                :placeholder="$t('common.pla.pleaseInput')"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <template>
                    <el-button @click="cancelFundingDialog()">{{ $t('common.btn.cancel') }}</el-button>
                    <el-button
                        type="primary"
                        @click="confirmFunding('fundingForm')"
                    >{{ $t('common.btn.confirm') }}</el-button>
                </template>
            </span>
        </el-dialog>
        <!-- 输入资助信息弹框结束 -->
        <!-- 是否要指定专家弹框开始 -->
        <el-dialog
            :title="$t('exchangeProjectAudit.specifyExperts')"
            width="20%"
            :visible.sync="whetherToExpertsDialog"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <div class="dialog-footer" style="text-align: center;">
                <template>
                    <el-button
                        type="primary"
                        @click="specify()"
                    >{{ $t('exchangeProjectAudit.specify') }}</el-button>
                    <el-button
                        type="primary"
                        @click="notSpecify()"
                    >{{ $t('exchangeProjectAudit.notSepcify') }}</el-button>
                </template>
            </div>
        </el-dialog>
        <!-- 是否要指定专家弹框结束 -->
        <!-- 指定专家弹框开始 -->
        <template v-if="specifyExpertsDialog">
            <el-dialog
                :title="$t('exchangeProjectAudit.specifyPeople')"
                width="50%"
                :visible.sync="specifyExpertsDialog"
                :close-on-click-modal="false"
                :close-on-press-escape="false"
            >
                <experts-info @change-current-experts="changeCurrentExperts"></experts-info>
                <span slot="footer" class="dialog-footer">
                    <template>
                        <el-button @click="cancelSpecify()">{{ $t('common.btn.cancel') }}</el-button>
                        <el-button
                            type="primary"
                            @click="specifyExperts()"
                        >{{ $t('common.btn.confirm') }}</el-button>
                    </template>
                </span>
            </el-dialog>
        </template>
        <!-- 指定专家弹框结束 -->
        <!-- 导出弹框开始 -->
        <edu-export-dialog
            :disabled="exportButton"
            :title="$t('message.prompt')"
            ref="downloadRef"
            :data="exportResult"
        ></edu-export-dialog>
        <!-- 导出弹框结束 -->
    </div>
</template>
<script>
import baseUrl from 'common/src/api/externalExchange/env'
import UTILS from 'common/src/utils/utils'
import { queryDic } from 'common/src/api/dictionary'
import innovativeApi from 'common/src/api/innovative/innovative'
import externalExchangeApi from 'common/src/api/externalExchange/externalExchange'
import courseEvaluationApi from 'common/src/api/teachingEvaluation/courseEvaluation'
import auditGoAbroadForSelect from './auditGoAbroadForSelect'
import auditGoAbroad from './auditGoAbroad'
import selectReturnHome from './selectReturnHome'
import returnHomeSelect from 'common/src/views/externalExchange/exchangeProjectApp/returnHomeSelect'
import auditReturnHome from './auditReturnHome'
import expertsInfo from 'common/src/views/externalExchange/common/expertsInfo'
export default {
    components: {
        'audit-go-abroad-for-select': auditGoAbroadForSelect,
        'audit-go-abroad': auditGoAbroad,
        'select-return-home': selectReturnHome,
        'return-home-select': returnHomeSelect,
        'audit-return-home': auditReturnHome,
        'experts-info': expertsInfo
    },
    data() {
        return {
            auths: [],
            userInfo: {},
            indexKey: 1,
            tabTitle: '',
            permitToBatchDownloadFiles: false,
            permitToBatchPass: false,
            permitToBatchPassManage: false,
            permitToBatchNextAudit: false,
            permitToBatchNoNextAudit: false,
            permitToBatchNoPass: false,
            permitToBatchTurnDown: false,
            permitToBatchAudit: false,
            experts:false,
            permitToBatchExport: false,
            permitToSelectGoAbroad: false,
            permitToAuditGoAbroad: false,
            permitToAuditReturnHomeBX: false,
            permitToSelectReturnHomeBX: false,
            permitToApplyReturnHomeBX: false,
            permitToSpecifyExperts: false,
            permitToManageCollege: false,
            permitToBXStatus: false,
            permitToBXOperate: false,
            permitToDownloadFunding: false,
            permitToDownExperts:false,
            dialogVisible: false,
            multipleSelection: [],
            queryForm: {
                pageNum_: 1,
                pageSize_: 20,
                total_: 0,
                condition: {
                    projectSubCategory: '',
                    studentFaculty: '',
                    studentProfession: '',
                    projectNationCode: '',
                    projectCollegeId: '',
                    projectStartTimeStr: '',
                    projectEndTimeStr: '',
                    studentParam: '',
                    applyStatus: '',
                    backApplyStatus: ''
                }
            },
            options: {
                // 项目子类别
                projectSubCategory: [],
                // 学院
                studentFaculty: [],
                // 专业
                studentProfession: [],
                // 国家
                projectNationCode: [],
                // 合作大学
                projectCollegeId: [],
                // 出国审核状态
                applyStatus: [
                    {
                        key: 0,
                        label: '不通过',
                        value: 0
                    },
                    {
                        key: 2,
                        label: '已提交',
                        value: 2
                    },
                    {
                        key: 3,
                        label: '待审核',
                        value: 3
                    },
                    {
                        key: 4,
                        label: '通过',
                        value: 4
                    }
                ],
                // 报销审核状态
                backApplyStatus: [
                    {
                        key: 2,
                        label: '已提交',
                        value: 2
                    },
                    {
                        key: 3,
                        label: '待审核',
                        value: 3
                    },
                    {
                        key: 4,
                        label: '通过',
                        value: 4
                    }
                ]
            },
            dialogMode: 'add',
            dataList: [],
            exportButton: false,
            exportResult: null,
            auditMode: '0', // '0'为学校管理员角色，'1'为专家，'2'为学院工作人员
            applyId: '',
            backId: '',
            applyActExpert: '', // 是否选择专家
            subsidizeFillIn: '', // 0：不填写资助，1：填写资助(判断是否是终审)
            isTeacher: true,
            title: '',
            dialogForm: {
                content: ''
            },
            auditType: '',
            auditStatus: {
                returnHome: false
            },
            showProcess: false,
            whetherToExpertsDialog: false,
            specifyExpertsDialog: false,
            currentExpertCode: '',
            projectStartTime: '',
            projectEndTime: '',
            fundingDialogVisible: false,
            fundingForm: {
                projectFundingPeriod: '',
                subsidizeStandard: '',
                subsidizeAmount: ''
            },
            fundingObject: {
                projectFundingPeriod: '',
                subsidizeStandard: '',
                subsidizeAmount: ''
            },
            notSpecifyExperts: false,
            firstAudit: false,
            projectSubCategory: ''
        }
    },
    filters: {
        goAbroadAuditStatus(val) {
            switch (val) {
                case 0:
                    return '不通过'
                case 1:
                    return '草稿'
                case 2:
                    return '已提交'
                case 3:
                    return '待审核'
                case 4:
                    return '通过'
                case 5:
                    return '驳回'
                default:
                    return val
            }
        },
        getApplyStatusType(val) {
            switch (val) {
                case 0:
                    return 'danger'
                case 1:
                    return 'info'
                case 2:
                    return 'info'
                case 3:
                    return 'info'
                case 4:
                    return 'success'
                case 5:
                    return 'warning'
                case 6:
                    return 'success'
                default:
                    return val
            }
        },
        returnHomeReimbursement(val) {
            switch (val) {
                case 1:
                    return '草稿'
                case 2:
                    return '已提交'
                case 3:
                    return '待审核'
                case 4:
                    return '通过'
                case 5:
                    return '驳回'
                case 6:
                    return '已完成'
                default:
                    return val
            }
        },
        participantPass(val) {
            switch (val) {
                case 1:
                    return '是'
                case 2:
                    return '否'
                case 3:
                    return '否'
            }
        },
        getAdmissionType(val) {
            switch (val) {
                case 1:
                    return 'success'
                case 2:
                    return 'info'
                case 3:
                    return 'info'
                default:
                    return ''
            }
        }
    },
    computed: {
        // 项目开始时间
        xmkssjPickerOptions() {
            let _this = this
            return {
                disabledDate: value => {
                    if (_this.queryForm.condition.projectEndTimeStr) {
                        // 项目开始时间必须小于项目截止时间
                        if (
                            value.getTime() >
                            new Date(_this.queryForm.condition.projectEndTimeStr).getTime()
                        ) {
                            return true
                        }
                    }
                    return false
                }
            }
        },
        // 项目结束时间
        xmjssjPickerOptions() {
            let _this = this
            return {
                disabledDate: value => {
                    if (_this.queryForm.condition.projectStartTimeStr) {
                        // 评分截止时间必须大于评分开始时间
                        if (
                            value.getTime() + 24 * 60 * 60 * 1000 <
                            new Date(_this.queryForm.condition.projectStartTimeStr).getTime()
                        ) {
                            return true
                        }
                    }
                    return false
                }
            }
        }
    },
    async created() {
        // 获取当前用户auths权限
        if (localStorage.getItem('sessiondata')) {
            if (JSON.parse(localStorage.getItem('sessiondata')).auths) {
                this.auths = JSON.parse(localStorage.getItem('sessiondata')).auths
            }
            if (JSON.parse(localStorage.getItem('sessiondata')).mockUser) {
                this.userInfo = JSON.parse(localStorage.getItem('sessiondata')).mockUser
            } else {
                this.userInfo = JSON.parse(localStorage.getItem('user'))
            }
        }
        this.initOptions()
        // 判断当前登录的角色 acdemic学校管理员>leader学院领导>principal学院负责人>teacher导师
        await this.getAllCollege()

        // 获取项目子类别
        externalExchangeApi
            .getXMZLBOptions({
                selectFlag: 0,
                parentId: 2
            })
            .then(res => {
                if (res.code === 200 && res.data.length > 0) {
                    this.options.projectSubCategory = res.data
                }
            })
        this.onSubmit()
    },
    mounted() {},
    methods: {
        // 校验特殊字符$
        checkSpecial(rule, value, callback) {
            let regEn = /[`$]/im
            if (regEn.test(value)) {
                callback(new Error(this.$t('graduateBase.specialText')))
            } else {
                callback()
            }
        },
        // 校验申请期限
        checkPositiveInteger(rule, value, callback) {
            let regExp = /^[1-9]\d*$/
            if (!regExp.test(value)) {
                callback(new Error(this.$t('externamExchangeBase.validatePositiveInteger')))
            } else {
                callback()
            }
        },
        reset() {
            for (let key in this.queryForm.condition) {
                if (this.permitToManageCollege && key === 'studentFaculty') {
                } else {
                    this.queryForm.condition[key] = ''
                }
            }
            if (!this.permitToManageCollege) {
                this.options.studentProfession = []
            }
            this.options.projectCollegeId = []
            this.onSubmit()
        },
        getListData() {
            externalExchangeApi.getProjectApplicationList(this.queryForm).then(res => {
                this.dataList = res.data.list
                this.queryForm.total_ = res.data.total_
            })
        },
        onSubmit() {
            this.queryForm.pageNum_ = 1
            this.getListData()
        },
        handleSelectionChange(val) {
            this.multipleSelection = val
        },
        handleSizeChange(val) {
            this.queryForm.pageSize_ = val
            this.getListData()
        },
        handleCurrentChange(val) {
            this.queryForm.pageNum_ = val
            this.getListData()
        },
        // 获取学院
        async getAllCollege() {
            // await innovativeApi.getAllFaculty().then(res => {
            //   if (res.code === 200) {
            //     if (Array.isArray(res.data) &&  res.data.length > 0) {
            //       res.data.map(item => {
            //         this.options.studentFaculty.push({
            //           label: (this.$store.getters.language === 'cn' || !this.$store.getters.language) ? item.deptName : item.deptNameEn,
            //           value: item.deptCode,
            //           key: item.deptCode
            //         });
            //       });
            //     }
            //   }
            // });
            // 筛选条件字典查询
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: [
                    'X_YX' // 学院
                ]
            }
            await queryDic(data).then(res => {
                UTILS.fillSelect(
                    {
                        studentFaculty: 'X_YX' // 学院
                    },
                    res.data,
                    this.options
                )
            })
        },
        async initOptions() {
            // 筛选条件字典查询
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: [
                    'G_GJQU' // 国家
                ]
            }
            await queryDic(data).then(res => {
                UTILS.fillSelect(
                    {
                        projectNationCode: 'G_GJQU' // 国家
                    },
                    res.data,
                    this.options
                )
            })
        },
        // 修改学院
        changeCollege(val) {
            this.options.studentProfession = []
            this.queryForm.condition.studentProfession = ''
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: ['G_ZY'],
                filter: {
                    prefix: [val],
                    specilaCode: 'XY2ZY',
                    facultys: [val]
                }
            }
            queryDic(data).then(res => {
                UTILS.fillSelect(
                    {
                        studentProfession: 'G_ZY' // 专业
                    },
                    res.data,
                    this.options
                )
            })
        },
        // 修改国家
        changeNation(val) {
            this.queryForm.condition.projectCollegeId = ''
            this.options.projectCollegeId = []
            // 获取合作大学
            if (val) {
                externalExchangeApi
                    .getCollegeByNationCode({
                        code: val
                    })
                    .then(res => {
                        if (res.code === 200) {
                            this.options.projectCollegeId = res.data
                        }
                    })
            } else {
                this.options.projectCollegeId = []
            }
        },
        // 批量下载附件判断
        downloadFileBatchly(type) {
            // type值判断，1：出国2：回国
            let currentIds = []
            if (this.multipleSelection.length > 0) {
                this.multipleSelection.forEach(element => {
                    currentIds.push(element.applyId)
                })
            }
            externalExchangeApi
                .getBatchFile({
                    type: Number(type),
                    projectSubCategory: this.queryForm.condition.projectSubCategory,
                    studentFaculty: this.queryForm.condition.studentFaculty,
                    studentProfession: this.queryForm.condition.studentProfession,
                    projectNationCode: this.queryForm.condition.projectNationCode,
                    projectCollegeId: this.queryForm.condition.projectCollegeId,
                    projectStartTimeStr: this.queryForm.condition.projectStartTimeStr,
                    projectEndTimeStr: this.queryForm.condition.projectEndTimeStr,
                    studentParam: this.queryForm.condition.studentParam,
                    participantPass: '',
                    applyStatus: this.queryForm.condition.applyStatus,
                    backApplyStatus: this.queryForm.condition.backApplyStatus,
                    applyIds: currentIds
                })
                .then(res => {
                    if (res.code === 200) {
                        if (res.data.length === 0) {
                            this.$message.error(this.$t('externamExchangeBase.hasNoFile'))
                            return
                        } else {
                            this.exportResult = null
                            this.$refs.downloadRef.open()
                            this.exportButton = true
                            let params = JSON.parse(JSON.stringify(res.data))
                            setTimeout(() => {
                                externalExchangeApi
                                    .batchDownload(params)
                                    .then(resp => {
                                        if (resp.code === 200 && resp.data.key) {
                                            this.batchNormalDelayRequest(resp.data.key)
                                        }
                                    })
                                    .catch(e => {
                                        this.$refs.downloadRef.close()
                                        this.exportButton = false
                                    })
                            }, 2000)
                        }
                    }
                })
        },
        // 非管理员批量通过
        passBatchly() {
            // 未勾选数据
            if (this.multipleSelection.length === 0) {
                this.$message.error(this.$t('externamExchangeBase.pleaseChoose'))
                return
            }
            // 勾选一条数据
            if (this.multipleSelection.length === 1) {
                // 判定当前数据是否不可审核
                let hasCanNotBeAudited = false
                let goAbroad = false
                let returnHome = false
                for (let i = 0; i < this.multipleSelection.length; i++) {
                    if (this.multipleSelection[i].back) {
                        if (!this.multipleSelection[i].back.canAudit) {
                            hasCanNotBeAudited = true
                        }
                    } else if (
                        !this.multipleSelection[i].back &&
                        !this.multipleSelection[i].canAudit
                    ) {
                        hasCanNotBeAudited = true
                    }
                    if (this.multipleSelection[i].canAudit) {
                        goAbroad = true
                    }
                    if (this.multipleSelection[i].back && this.multipleSelection[i].back.canAudit) {
                        returnHome = true
                    }
                }
                // 包含不可审核的数据
                if (hasCanNotBeAudited) {
                    this.$message.error(this.$t('externamExchangeBase.notCanBeAudited'))
                    return
                }
                this.auditType = 'pass'
                this.auditStatus = {
                    goAbroad: goAbroad,
                    returnHome: returnHome
                }
                this.title = this.$t('externamExchangeBase.batchPass')
                this.dialogVisible = true
            }
            // 勾选多条数据
            if (this.multipleSelection.length > 1) {
                // 判定是否包含两种审核数据
                let goAbroad = false
                let returnHome = false
                let hasCanNotBeAudited = false
                for (let i = 0; i < this.multipleSelection.length; i++) {
                    if (this.multipleSelection[i].back) {
                        if (!this.multipleSelection[i].back.canAudit) {
                            hasCanNotBeAudited = true
                        }
                    } else if (
                        !this.multipleSelection[i].back &&
                        !this.multipleSelection[i].canAudit
                    ) {
                        hasCanNotBeAudited = true
                    }
                    if (this.multipleSelection[i].canAudit) {
                        goAbroad = true
                    }
                    if (this.multipleSelection[i].back && this.multipleSelection[i].back.canAudit) {
                        returnHome = true
                    }
                }
                // 包含不可审核的数据
                if (hasCanNotBeAudited) {
                    this.$message.error(this.$t('externamExchangeBase.notCanBeAudited'))
                    return
                }
                // 同时包含出国和回国都可审核的数据
                if (goAbroad && returnHome) {
                    this.$message.error(this.$t('externamExchangeBase.hasTwoCanBeAudited'))
                    return
                }
                this.auditType = 'pass'
                this.auditStatus = {
                    goAbroad: goAbroad,
                    returnHome: returnHome
                }
                this.title = this.$t('externamExchangeBase.batchPass')
                this.dialogVisible = true
            }
        },
        // 学校管理员批量通过
        managerPassBatchly() {
            this.firstAudit = false
            // 未勾选数据
            if (this.multipleSelection.length === 0) {
                this.$message.error(this.$t('externamExchangeBase.pleaseChoose'))
                return
            }
            // 勾选一条数据
            if (this.multipleSelection.length === 1) {
                // 判定当前数据是否不可审核
                let hasCanNotBeAudited = false
                let goAbroad = false
                let returnHome = false
                // 由是否要指定专家来判定是否为初审
                let mustToSpecifyExpert = false
                let projectType = ''
                for (let i = 0; i < this.multipleSelection.length; i++) {
                    projectType = this.multipleSelection[i].projectSubCategory
                    mustToSpecifyExpert =
                        this.multipleSelection[i].applyActExpert === 0 ? false : true
                    if (this.multipleSelection[i].back) {
                        if (!this.multipleSelection[i].back.canAudit) {
                            hasCanNotBeAudited = true
                        }
                    } else if (
                        !this.multipleSelection[i].back &&
                        !this.multipleSelection[i].canAudit
                    ) {
                        hasCanNotBeAudited = true
                    }
                    if (this.multipleSelection[i].canAudit) {
                        goAbroad = true
                    }
                    if (this.multipleSelection[i].back && this.multipleSelection[i].back.canAudit) {
                        returnHome = true
                    }
                }
                // 包含不可审核的数据
                if (hasCanNotBeAudited) {
                    this.$message.error(this.$t('externamExchangeBase.notCanBeAudited'))
                    return
                }
                // 可审核
                // 出国
                if (goAbroad) {
                    // 国家公派
                    if (projectType === 6) {
                        // 初审需要指定专家
                        if (mustToSpecifyExpert) {
                            this.auditType = 'pass'
                            this.auditStatus = {
                                goAbroad: goAbroad,
                                returnHome: returnHome
                            }
                            this.whetherToExpertsDialog = true
                        } else {
                            // 终审
                            this.auditType = 'pass'
                            this.title = this.$t('externamExchangeBase.batchPass')
                            this.auditStatus = {
                                goAbroad: goAbroad,
                                returnHome: returnHome
                            }
                            this.dialogVisible = true
                        }
                    }
                    // 短期访学
                    if (projectType === 7) {
                        // 初审需要指定专家
                        if (mustToSpecifyExpert) {
                            // 可审核-出国-短期访学-初审(场景)
                            this.firstAudit = true
                            this.auditType = 'pass'
                            this.auditStatus = {
                                goAbroad: goAbroad,
                                returnHome: returnHome
                            }
                            this.whetherToExpertsDialog = true
                        } else {
                            // 终审
                            this.auditType = 'pass'
                            this.title = this.$t('externamExchangeBase.batchPass')
                            this.auditStatus = {
                                goAbroad: goAbroad,
                                returnHome: returnHome
                            }
                            this.fundingDialogVisible = true
                        }
                    }
                }
                // 回国
                if (returnHome) {
                    // 短期访学
                    if (projectType === 7) {
                        this.auditType = 'pass'
                        this.title = this.$t('externamExchangeBase.batchPass')
                        this.auditStatus = {
                            goAbroad: goAbroad,
                            returnHome: returnHome
                        }
                        this.dialogVisible = true
                    }
                }
            }
            // 勾选多条数据
            if (this.multipleSelection.length > 1) {
                // 判定是否包含两种审核数据
                let goAbroad = false
                let returnHome = false
                let hasCanNotBeAudited = false
                // 需要指定专家
                let mustToSpecifyExpert = false
                // 不需要指定专家
                let notSpecifyExpert = false
                // 是否是国家公派
                let gjgpProject = false
                // 是否是短期访学
                let dqfxProject = false
                for (let i = 0; i < this.multipleSelection.length; i++) {
                    if (this.multipleSelection[i].projectSubCategory === 6) {
                        gjgpProject = true
                    }
                    if (this.multipleSelection[i].projectSubCategory === 7) {
                        dqfxProject = true
                    }
                    if (this.multipleSelection[i].applyActExpert === 0) {
                        notSpecifyExpert = true
                    }
                    if (this.multipleSelection[i].applyActExpert === 1) {
                        mustToSpecifyExpert = true
                    }
                    if (this.multipleSelection[i].back) {
                        if (!this.multipleSelection[i].back.canAudit) {
                            hasCanNotBeAudited = true
                        }
                    } else if (
                        !this.multipleSelection[i].back &&
                        !this.multipleSelection[i].canAudit
                    ) {
                        hasCanNotBeAudited = true
                    }
                    // if (!this.multipleSelection[i].canAudit || (this.multipleSelection[i].back && !this.multipleSelection[i].back.canAudit)) {
                    //   hasCanNotBeAudited = true
                    // }
                    if (this.multipleSelection[i].canAudit) {
                        goAbroad = true
                    }
                    if (this.multipleSelection[i].back && this.multipleSelection[i].back.canAudit) {
                        returnHome = true
                    }
                }
                // 不可审核场景
                // 包含不可审核的数据
                if (hasCanNotBeAudited) {
                    this.$message.error(this.$t('externamExchangeBase.notCanBeAudited'))
                    return
                }
                // 可审核场景
                // 同时包含出国和回国都可审核的数据
                if (goAbroad && returnHome) {
                    this.$message.error(this.$t('externamExchangeBase.hasTwoCanBeAudited'))
                    return
                }
                // 出国
                if (goAbroad) {
                    // 同时包含两种出国项目，由于国家公派无需填写资助信息，无法判定是否要填写资助信息，不可审核
                    if (gjgpProject && dqfxProject) {
                        this.$message.error(this.$t('externamExchangeBase.hasTwoProjects'))
                        return
                    }
                    // 同时包含两种审核状态(初审+终审)，无法判定走哪步，不可操作数据
                    if (mustToSpecifyExpert && notSpecifyExpert) {
                        this.$message.error(this.$t('externamExchangeBase.hasTwoAuditStatus'))
                        return
                    }
                    // 国家公派
                    if (gjgpProject) {
                        // 初审需要指定专家
                        if (mustToSpecifyExpert) {
                            this.auditType = 'pass'
                            this.auditStatus = {
                                goAbroad: goAbroad,
                                returnHome: returnHome
                            }
                            this.whetherToExpertsDialog = true
                        } else {
                            // 终审
                            this.auditType = 'pass'
                            this.title = this.$t('externamExchangeBase.batchPass')
                            this.auditStatus = {
                                goAbroad: goAbroad,
                                returnHome: returnHome
                            }
                            this.dialogVisible = true
                        }
                    }
                    // 短期访学
                    if (dqfxProject) {
                        // 初审需要指定专家
                        if (mustToSpecifyExpert) {
                            // 可审核-出国-短期访学-初审(场景)
                            this.firstAudit = true
                            this.auditType = 'pass'
                            this.auditStatus = {
                                goAbroad: goAbroad,
                                returnHome: returnHome
                            }
                            this.whetherToExpertsDialog = true
                        } else {
                            // 终审
                            this.auditType = 'pass'
                            this.title = this.$t('externamExchangeBase.batchPass')
                            this.auditStatus = {
                                goAbroad: goAbroad,
                                returnHome: returnHome
                            }
                            this.fundingDialogVisible = true
                        }
                    }
                }
                // 回国
                if (returnHome) {
                    // 短期访学
                    if (dqfxProject) {
                        this.auditType = 'pass'
                        this.title = this.$t('externamExchangeBase.batchPass')
                        this.auditStatus = {
                            goAbroad: goAbroad,
                            returnHome: returnHome
                        }
                        this.dialogVisible = true
                    }
                }
            }
        },
        // 批量不通过
        notPassBatchly() {
            let typeObj = this.judgeCanBeOperateAndGetType('notPass')
            if (typeObj) {
                this.auditType = 'notPass'
                this.auditStatus = typeObj
                this.title = this.$t('externamExchangeBase.batchNotPass')
                this.dialogVisible = true
            }
        },
        // 批量驳回
        turnDownBatchly() {
            let typeObj = this.judgeCanBeOperateAndGetType('turnDown')
            if (typeObj) {
                this.auditType = 'turnDown'
                this.auditStatus = typeObj
                this.title = this.$t('externamExchangeBase.batchReject')
                this.dialogVisible = true
            }
        },
        // 批量评审
        batchAudit() {
            let typeObj = this.judgeCanBeOperateAndGetType('batchAudit')
            if (typeObj) {
                this.auditType = 'batchAudit'
                this.auditStatus = typeObj
                this.title = this.$t('externamExchangeBase.batchAudit')
                this.dialogVisible = true
            }
        },
        // 判断是否可以操作以及获取操作类型
        judgeCanBeOperateAndGetType(operateType, auditStatus) {
            if (this.multipleSelection.length === 0) {
                this.$message.error(this.$t('externamExchangeBase.pleaseChoose'))
                return false
            } else {
                let goAbroad = false
                let returnHome = false
                let chooseExperts = true
                let hasCanNotBeAudited = false
                let cannotNoPass = false
                for (let i = 0; i < this.multipleSelection.length; i++) {
                    // 出国
                    if (this.multipleSelection[i].canAudit) {
                        goAbroad = true
                    }
                    // 回国
                    if (this.multipleSelection[i].back && this.multipleSelection[i].back.canAudit) {
                        returnHome = true
                    }
                    // 不可审核
                    if (this.multipleSelection[i].back) {
                        if (!this.multipleSelection[i].back.canAudit) {
                            hasCanNotBeAudited = true
                        }
                    } else if (
                        !this.multipleSelection[i].back &&
                        !this.multipleSelection[i].canAudit
                    ) {
                        hasCanNotBeAudited = true
                    }
                    // 短访回国报销没有不通过功能
                    if (operateType === 'notPass') {
                        if (
                            this.multipleSelection[i].back &&
                            this.multipleSelection[i].back.canAudit &&
                            this.multipleSelection[i].projectSubCategory === 7
                        ) {
                            cannotNoPass = true
                        }
                    }
                }
                // 如果同时包含出国和回国,则不可审核
                if (goAbroad && returnHome) {
                    this.$message.error(this.$t('externamExchangeBase.hasTwoCanBeAudited'))
                    return false
                }
                // 如果审核状态为否的也不可审核
                if (hasCanNotBeAudited) {
                    this.$message.error(this.$t('externamExchangeBase.notCanBeAudited'))
                    return false
                }
                // 短访回国报销没有不通过功能
                if (cannotNoPass) {
                    this.$message.error(this.$t('externamExchangeBase.cantNoPass'))
                    return false
                }
                return {
                    goAbroad,
                    returnHome
                }
            }
        },
        // 确认
        confirm() {
            // 非管理员通过
            if (this.auditType === 'pass' || this.auditType === 'batchAudit') {
                // 出国-通过
                if (this.auditStatus.goAbroad) {
                    if (this.auditType === 'batchAudit' && !this.dialogForm.content) {
                        this.$message.error(this.$t('exchangeProjectAudit.requireAuditOpinion'))
                        return
                    }
                    this.goAbroadAudit(1)
                }
                // 回国-通过
                if (this.auditStatus.returnHome) {
                    this.returnHomeAudit(1)
                }
            }
            // 不通过
            if (this.auditType === 'notPass') {
                // 出国-不通过
                if (this.auditStatus.goAbroad) {
                    this.goAbroadAudit(0)
                }
                // 回国-不通过
                if (this.auditStatus.returnHome) {
                    this.returnHomeAudit(0)
                }
            }
            // 驳回
            if (this.auditType === 'turnDown') {
                if (this.dialogForm.content) {
                    // 出国-驳回
                    if (this.auditStatus.goAbroad) {
                        this.goAbroadAudit(2)
                    }
                    // 回国-驳回
                    if (this.auditStatus.returnHome) {
                        this.returnHomeAudit(2)
                    }
                } else {
                    this.$message.error(this.$t('exchangeProjectAudit.requireAuditOpinion'))
                }
            }
        },
        // 出国审核
        goAbroadAudit(type) {
            this.$refs['dialogForm'].validate(valid => {
                if (valid) {
                    let params = {
                        type: type,
                        content: this.dialogForm.content,
                        applyIds: this.multipleSelection.map(value => {
                            return value.applyId
                        })
                    }
                    let hasInfo = false
                    for (let key in this.fundingObject) {
                        if (this.fundingObject[key]) {
                            hasInfo = true
                        }
                    }
                    if (hasInfo) {
                        params['subsidizePeriod'] = Number(this.fundingObject.projectFundingPeriod)
                        params['subsidizeStandard'] = this.fundingObject.subsidizeStandard
                        params['subsidizeAmount'] = this.fundingObject.subsidizeAmount
                    }
                    externalExchangeApi.auditApplyProjectApp(params).then(res => {
                        if (res.code === 200) {
                            for (let key in this.fundingObject) {
                                this.fundingObject[key] = ''
                            }
                            this.$refs['dialogForm'].resetFields()
                            this.dialogVisible = false
                            this.$message.success(this.$t('externamExchangeBase.auditSuccessfully'))
                            this.onSubmit()
                        }
                    })
                } else {
                    setTimeout(() => {
                        let isError = document.getElementsByClassName('is-error')
                        if (isError[0] && isError[0] && isError[0].querySelector('input')) {
                            isError[0].querySelector('input').focus()
                        }
                    }, 1)
                }
            })
        },
        // 回国审核
        returnHomeAudit(type) {
            this.$refs['dialogForm'].validate(valid => {
                if (valid) {
                    externalExchangeApi
                        .auditReturnHomeReimburse({
                            type: type,
                            content: this.dialogForm.content,
                            backIds: this.multipleSelection.map(value => {
                                return value.back.backId
                            })
                        })
                        .then(res => {
                            if (res.code === 200) {
                                this.$refs['dialogForm'].resetFields()
                                this.dialogVisible = false
                                this.$message.success(
                                    this.$t('externamExchangeBase.auditSuccessfully')
                                )
                                this.onSubmit()
                            }
                        })
                } else {
                    setTimeout(() => {
                        let isError = document.getElementsByClassName('is-error')
                        if (isError[0] && isError[0] && isError[0].querySelector('input')) {
                            isError[0].querySelector('input').focus()
                        }
                    }, 1)
                }
            })
        },
        // 轮询直到获取key值的接口返回
        cycleToGetKey() {
            setTimeout(() => {
                let currentIds = []
                if (this.multipleSelection.length > 0) {
                    this.multipleSelection.forEach(element => {
                        currentIds.push(element.applyId)
                    })
                }
                externalExchangeApi
                    .exportExternalExchangeRecord({
                        projectSubCategory: this.queryForm.condition.projectSubCategory,
                        studentFaculty: this.queryForm.condition.studentFaculty,
                        studentProfession: this.queryForm.condition.studentProfession,
                        projectNationCode: this.queryForm.condition.projectNationCode,
                        projectCollegeId: this.queryForm.condition.projectCollegeId,
                        projectStartTimeStr: this.queryForm.condition.projectStartTimeStr,
                        projectEndTimeStr: this.queryForm.condition.projectEndTimeStr,
                        studentParam: this.queryForm.condition.studentParam,
                        participantPass: '',
                        applyStatus: this.queryForm.condition.applyStatus,
                        backApplyStatus: this.queryForm.condition.backApplyStatus,
                        applyIds: currentIds
                    })
                    .then(res => {
                        if (res.code === 200 && res.data.key) {
                            this.$refs.downloadRef.close()
                            this.exportButton = false
                            this.normalDelayRequest(res.data.key)
                        } else {
                            this.cycleToGetKey()
                        }
                    })
            }, 2000)
        },
        // 导出异步
        delayRequest(key) {
            setTimeout(() => {
                externalExchangeApi.downloadGetKey(key).then(res => {
                    this.exportResult = res.data
                    if (res.code == 200 && res.data.status) {
                        this.exportButton = false
                        let path = `${baseUrl}/export/file?path=` + res.data.path
                        // window.open(path);
                        window.location.href = path
                        this.$message.success(this.$t('result.exportSuccessfully'))
                        this.$refs.downloadRef.close()
                    } else {
                        this.delayRequest(key)
                    }
                })
            }, 2000)
        },
        // 导出异步-批量
        batchDelayRequest(key) {
            setTimeout(() => {
                externalExchangeApi.downloadGetKey(key).then(res => {
                    this.exportResult = res.data
                    if (res.code == 200 && res.data.status) {
                        this.exportButton = false
                        let path = `${baseUrl}/export/exportZip?path=` + res.data.path
                        window.open(path)
                        // window.location.href = path;
                        this.$message.success(this.$t('result.exportSuccessfully'))
                        this.$refs.downloadRef.close()
                    } else {
                        this.batchDelayRequest(key)
                    }
                })
            }, 2000)
        },
        // Normal导出异步
        normalDelayRequest(key) {
            setTimeout(() => {
                externalExchangeApi.downloadGetKey(key).then(res => {
                    this.exportResult = res.data
                    if (res.code == 200 && res.data.status) {
                        this.exportButton = false
                        let path = `${baseUrl}/export/file?path=` + res.data.path
                        // window.open(path);
                        window.location.href = path
                        this.$message.success(this.$t('result.exportSuccessfully'))
                        this.$refs.downloadRef.close()
                    } else {
                        this.delayRequest(key)
                    }
                })
            }, 2000)
        },
        // Normal导出异步-批量
        batchNormalDelayRequest(key) {
            externalExchangeApi.downloadGetKey(key).then(res => {
                this.exportResult = res.data
                if (res.code == 200 && res.data.status) {
                    this.exportButton = false
                    let path = `${baseUrl}/export/exportZip?path=` + res.data.path
                    window.open(path)
                    // window.location.href = path;
                    this.$message.success(this.$t('externamExchangeBase.downSuccess'))
                    this.$refs.downloadRef.close()
                } else {
                    this.batchDelayRequest(key)
                }
            })
        },
        // 批量导出
        exportBatchly() {
            // 1、第一步：调该接口，获取key值以及msg中的文件名
            // 2、第二步：将key值放入接口传参
            // 3、第三步：传入path值以及name(msg中的文件名)值，下载文件
            if (this.dataList.length === 0) {
                this.$message.error(this.$t('externamExchangeBase.exportNoData'))
                return
            }
            this.exportResult = null
            this.$refs.downloadRef.open()
            this.exportButton = true
            this.cycleToGetKey()
        },
        // 下载资助函
        downloadFunding(row) {
            window.open(`${baseUrl}/pgOverseasExchangeApply/letter?applyId=` + row.applyId)
        },
        // 审核操作-查看出国
        selectGoAbroad(row) {
            this.applyId = row.applyId
            this.projectSubCategory = row.projectSubCategory
            this.subsidizeFillIn = row.subsidizeFillIn
            this.applyActExpert = row.applyActExpert
            this.indexKey = 2
        },
        // 审核操作-审核出国
        auditGoAbroad(row) {
            this.applyId = row.applyId
            this.projectSubCategory = row.projectSubCategory
            this.applyActExpert = row.applyActExpert
            this.subsidizeFillIn = row.subsidizeFillIn
            this.indexKey = 3
        },
        // 回到列表页
        changeProjectIndex() {
            this.indexKey = 1
            this.multipleSelection = []
            this.onSubmit()
        },
        // 关闭事件
        beforeClose: function(done) {
            this.$refs['dialogForm'].resetFields()
            this.onSubmit()
            this.dialogVisible = false
        },
        // 查看回国报销
        selectReturnHome(row) {
            this.applyId = row.applyId
            if (row.back) {
                this.backId = row.back.backId
            }
            if (row.changes.length > 0) {
                this.projectStartTime = row.changes[0].projectStartTime
                this.projectEndTime = row.changes[0].projectEndTime
            } else {
                this.projectStartTime = row.projectStartTime
                this.projectEndTime = row.projectEndTime
            }
            this.tabTitle =
                row.projectSubCategory === 6
                    ? this.$t('projectApplication.nationGovernGoHomeReportSelect')
                    : this.$t('projectApplication.shortTermVisitRuturnGovernSelect')
            if (row.projectSubCategory === 6) {
                this.showProcess = false
            } else {
                this.showProcess = true
            }
            this.projectSubCategory = row.projectSubCategory
            this.indexKey = 6
        },
        // 查看回国报销
        selectReturnHomeBX(row) {
            this.applyId = row.applyId
            if (row.back) {
                this.backId = row.back.backId
            }
            if (row.changes.length > 0) {
                this.projectStartTime = row.changes[0].projectStartTime
                this.projectEndTime = row.changes[0].projectEndTime
            } else {
                this.projectStartTime = row.projectStartTime
                this.projectEndTime = row.projectEndTime
            }
            if (row.projectSubCategory === 6) {
                this.showProcess = false
            } else {
                this.showProcess = true
            }
            this.projectSubCategory = row.projectSubCategory
            this.indexKey = 4
        },
        // 审核回国报销
        auditReturnHomeBX(row) {
            this.applyId = row.applyId
            if (row.back) {
                this.backId = row.back.backId
            }
            if (row.changes.length > 0) {
                this.projectStartTime = row.changes[0].projectStartTime
                this.projectEndTime = row.changes[0].projectEndTime
            } else {
                this.projectStartTime = row.projectStartTime
                this.projectEndTime = row.projectEndTime
            }
            this.indexKey = 5
        },
        // 指定专家
        specify() {
            this.whetherToExpertsDialog = false
            this.specifyExpertsDialog = true
        },
        // 不指定专家
        notSpecify() {
            externalExchangeApi
                .specifyExpertsAudit({
                    applyIdList: this.multipleSelection.map(value => {
                        return value.applyId
                    }),
                    teacherCode: ''
                })
                .then(res => {
                    if (res.code === 200) {
                        this.$message.success(this.$t('externamExchangeBase.operateSuccessfully'))
                        this.whetherToExpertsDialog = false
                        // 可审核-出国-短期访学-初审-不指定专家的场景
                        if (this.firstAudit) {
                            this.title = this.$t('externamExchangeBase.batchPass')
                            this.fundingDialogVisible = true
                        } else {
                            this.dialogVisible = true
                        }
                    }
                })
        },
        // 选择专家
        changeCurrentExperts(row) {
            this.currentExpertCode = row.teacherCode
        },
        // 取消指定专家
        cancelSpecify() {
            this.specifyExpertsDialog = false
        },
        // 确定指定专家
        specifyExperts() {
            externalExchangeApi
                .specifyExpertsAudit({
                    applyIdList: this.multipleSelection.map(value => {
                        return value.applyId
                    }),
                    teacherCode: this.currentExpertCode
                })
                .then(res => {
                    if (res.code === 200) {
                        this.$message.success(this.$t('externamExchangeBase.operateSuccessfully'))
                        this.specifyExpertsDialog = false
                        this.dialogVisible = true
                        this.title = this.$t('externamExchangeBase.batchPass')
                    }
                })
        },
        // 关闭资助信息弹框
        closeFundingDialog() {
            this.$refs['fundingForm'].resetFields()
            this.fundingDialogVisible = false
        },
        // 取消填写资助信息
        cancelFundingDialog() {
            this.$refs['fundingForm'].resetFields()
            this.fundingDialogVisible = false
            this.onSubmit()
        },
        // 确认保存资助信息
        confirmFunding() {
            this.$refs['fundingForm'].validate(valid => {
                if (valid) {
                    this.fundingObject = JSON.parse(JSON.stringify(this.fundingForm))
                    this.closeFundingDialog()
                    this.dialogVisible = true
                } else {
                    setTimeout(() => {
                        let isError = document.getElementsByClassName('is-error')
                        if (isError[0] && isError[0] && isError[0].querySelector('input')) {
                            isError[0].querySelector('input').focus()
                        }
                    }, 1)
                }
            })
        }
    },
    watch: {
        auths: {
            handler(newVal) {
                if (newVal && Array.isArray(newVal) && newVal.length > 0) {
                    newVal.some(item => {
                        // 导师-学院负责人-学院领导学院显示所在学院且不可修改
                        if (item.authCode === 'internCommuni-getLocalCollege') {
                            this.permitToManageCollege = true
                            this.queryForm.condition.studentFaculty = this.userInfo.faculty
                            this.changeCollege(this.queryForm.condition.studentFaculty)
                        }
                        // 批量下载附件
                        if (item.authCode === 'internCommuni-project-batch-download') {
                            this.permitToBatchDownloadFiles = true
                        }
                        // 非管理员的通过
                        if (item.authCode === 'internCommuni-project-audit-pass') {
                            this.permitToBatchPass = true
                            this.permitToBatchNoNextAudit = true
                        }
                        // 管理员的通过
                        if (item.authCode === 'internCommuni-project-audit-pass-manager') {
                            this.permitToBatchPassManage = true
                            this.permitToBatchNextAudit = true
                        }

                        // 管理员显示专家一栏
                        if (item.authCode === 'internCommuni-project-audit-show-experts') {
                            this.permitToSpecifyExperts = true
                        }
                        // 不通过
                        if (item.authCode === 'internCommuni-project-audit-noPass') {
                            this.permitToBatchNoPass = true
                        }
                        // 驳回
                        if (item.authCode === 'internCommuni-project-audit-turnDown') {
                            this.permitToBatchTurnDown = true
                        }
                        // 导出
                        if (item.authCode === 'internCommuni-project-audit-export') {
                            this.permitToBatchExport = true
                        }
                        // 查看（出国申请）
                        if (item.authCode === 'internCommuni-project-audit-select') {
                            this.permitToSelectGoAbroad = true
                        }
                        // 审核(出国申请)
                        if (item.authCode === 'internCommuni-project-audit-go-abroad-apply') {
                            this.permitToAuditGoAbroad = true
                        }
                        // 审核(短访回国报销)
                        if (item.authCode === 'internCommuni-project-audit-returnHome-baoxiao') {
                            this.permitToAuditReturnHomeBX = true
                        }
                        // 查看(短访回国报销)
                        if (item.authCode === 'internCommuni-project-audit-return-baoxiao-select') {
                            this.permitToSelectReturnHomeBX = true
                        }
                        // 申请短访回国报销
                        if (item.authCode === 'internCommuni-audit-returnHome-baoxiao-apply') {
                            this.permitToApplyReturnHomeBX = true
                        }
                        // 专家评审
                        if (item.authCode === 'internCommuni-audit-expertReview') {
                            this.permitToBatchAudit = true
                        }
                        // 报销状态
                        if (item.authCode === 'internCommuni-audit-baoxiao-status') {
                            this.permitToBXStatus = true
                        }
                        // 报销操作
                        if (item.authCode === 'internCommuni-audit-baoxiao-operate') {
                            this.permitToBXOperate = true
                        }
                        // 下载资助函
                        if (item.authCode === 'internCommuni-audit-download-funding') {
                            this.permitToDownloadFunding = true
                        }
                        // 除专家外展示回国报销/报道下载
                        if (item.authCode === 'internCommuni-project-audit-show-experts') {
                            this.permitToDownExperts = true
                        }
                    })
                }
            },
            deep: true,
            immediate: true
        }
    }
}
</script>
<style lang="scss" scoped>
.condition-title {
    color: #2b3b4e;
    font-size: 18px;
    line-height: 24px;
    font-weight: bold;
}
.sub-title {
    margin: 16px 0;
    font-size: 16px;
    color: #000020;
    letter-spacing: 0;
}
.exchange-project-audit-container ::v-deep {
    .el-dialog__body {
        word-break: break-all !important;
    }
}
</style>
